<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>PNG图标生成器</title>
    <style>
        body {
            margin: 0;
            padding: 20px;
            background: #f0f0f0;
            font-family: Arial, sans-serif;
        }
        
        .container {
            max-width: 800px;
            margin: 0 auto;
            background: white;
            padding: 30px;
            border-radius: 12px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.1);
        }
        
        .icon-preview {
            display: inline-block;
            margin: 15px;
            text-align: center;
            padding: 20px;
            background: #f8f9fa;
            border-radius: 8px;
            border: 2px solid #e9ecef;
        }
        
        canvas {
            border: 1px solid #ddd;
            border-radius: 4px;
            margin-bottom: 10px;
            display: block;
        }
        
        .download-btn {
            background: linear-gradient(135deg, #667eea, #764ba2);
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 14px;
            font-weight: 600;
            transition: all 0.3s ease;
        }
        
        .download-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
        }
        
        .instructions {
            background: linear-gradient(135deg, #667eea, #764ba2);
            color: white;
            padding: 20px;
            border-radius: 8px;
            margin-bottom: 30px;
        }
        
        .instructions h1 {
            margin: 0 0 10px 0;
            font-size: 24px;
        }
        
        .instructions p {
            margin: 5px 0;
            opacity: 0.9;
        }
        
        .step {
            background: #e3f2fd;
            padding: 15px;
            margin: 10px 0;
            border-radius: 6px;
            border-left: 4px solid #2196f3;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="instructions">
            <h1>🎨 酷炫图标生成器</h1>
            <p>为您的请求拦截器扩展生成现代化的图标</p>
            <p>点击下载按钮保存PNG格式的图标文件</p>
        </div>
        
        <div class="step">
            <strong>📋 使用步骤：</strong>
            <ol>
                <li>点击下面的下载按钮保存图标文件</li>
                <li>将下载的文件重命名为 icon16.png, icon32.png, icon48.png</li>
                <li>复制到项目的 dist/icons/ 目录</li>
                <li>在Chrome扩展管理页面重新加载扩展</li>
            </ol>
        </div>
        
        <div style="text-align: center;">
            <div class="icon-preview">
                <canvas id="canvas16" width="16" height="16"></canvas>
                <br>
                <button class="download-btn" onclick="downloadIcon('canvas16', 'icon16.png')">
                    📥 下载 16x16
                </button>
                <div>16x16 像素</div>
            </div>
            
            <div class="icon-preview">
                <canvas id="canvas32" width="32" height="32"></canvas>
                <br>
                <button class="download-btn" onclick="downloadIcon('canvas32', 'icon32.png')">
                    📥 下载 32x32
                </button>
                <div>32x32 像素</div>
            </div>
            
            <div class="icon-preview">
                <canvas id="canvas48" width="48" height="48"></canvas>
                <br>
                <button class="download-btn" onclick="downloadIcon('canvas48', 'icon48.png')">
                    📥 下载 48x48
                </button>
                <div>48x48 像素</div>
            </div>
        </div>
        
        <div class="step">
            <strong>🎯 图标特色：</strong>
            <ul>
                <li>现代渐变背景（蓝紫色到粉色）</li>
                <li>闪电符号代表快速拦截</li>
                <li>高清晰度矢量绘制</li>
                <li>适配Chrome扩展标准</li>
            </ul>
        </div>
    </div>
    
    <script>
        function createGradient(ctx, size) {
            const gradient = ctx.createLinearGradient(0, 0, size, size);
            gradient.addColorStop(0, '#667eea');
            gradient.addColorStop(0.5, '#764ba2');
            gradient.addColorStop(1, '#f093fb');
            return gradient;
        }
        
        function drawIcon(canvasId, size) {
            const canvas = document.getElementById(canvasId);
            const ctx = canvas.getContext('2d');
            
            // 清除画布
            ctx.clearRect(0, 0, size, size);
            
            // 绘制圆形背景
            ctx.beginPath();
            ctx.arc(size/2, size/2, size/2 - 1, 0, 2 * Math.PI);
            ctx.fillStyle = createGradient(ctx, size);
            ctx.fill();
            
            // 添加内阴影效果
            ctx.beginPath();
            ctx.arc(size/2, size/2, size/2 - 1, 0, 2 * Math.PI);
            ctx.strokeStyle = 'rgba(255,255,255,0.3)';
            ctx.lineWidth = 1;
            ctx.stroke();
            
            // 绘制闪电图标
            ctx.fillStyle = 'white';
            ctx.font = `bold ${Math.floor(size * 0.6)}px Arial`;
            ctx.textAlign = 'center';
            ctx.textBaseline = 'middle';
            ctx.shadowColor = 'rgba(0,0,0,0.3)';
            ctx.shadowBlur = 2;
            ctx.shadowOffsetY = 1;
            ctx.fillText('⚡', size/2, size/2);
            
            // 重置阴影
            ctx.shadowColor = 'transparent';
            ctx.shadowBlur = 0;
            ctx.shadowOffsetY = 0;
        }
        
        function downloadIcon(canvasId, filename) {
            const canvas = document.getElementById(canvasId);
            const link = document.createElement('a');
            link.download = filename;
            link.href = canvas.toDataURL('image/png');
            link.click();
            
            // 显示成功提示
            const btn = event.target;
            const originalText = btn.innerHTML;
            btn.innerHTML = '✅ 已下载';
            btn.style.background = '#4caf50';
            setTimeout(() => {
                btn.innerHTML = originalText;
                btn.style.background = 'linear-gradient(135deg, #667eea, #764ba2)';
            }, 2000);
        }
        
        // 页面加载时绘制所有图标
        window.onload = function() {
            drawIcon('canvas16', 16);
            drawIcon('canvas32', 32);
            drawIcon('canvas48', 48);
        };
    </script>
</body>
</html>
